import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)


const routes = [
  {
    path: '/',
    name: 'FuHeadlineHome',
    component: () => import(/* webpackChunkName: "about" */ '../views/FuHeadline/Home.vue')
  },
  {
    path: '/Article',
    name: 'FuHeadlineArticle',
    component: () => import(/* webpackChunkName: "about" */ '../views/FuHeadline/Article.vue')
  },
  {
    path: '/CreationCenter',
    name: 'CreationCenterHome',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/Home.vue')
  },
  {
    path: '/CreationCenter/Template',
    name: 'Template',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/Template.vue')
  },
  {
    path: '/Login',
    name: 'Login',
    component: () => import(/* webpackChunkName: "about" */ '../views/Login.vue')
  },
  {
    path: '/Register',
    name: 'Register',
    component: () => import(/* webpackChunkName: "about" */ '../views/Register.vue')
  },
  {
    path: '/CreationCenter/SendArticle',
    name: 'SendArticle',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/SendArticle.vue')
  },
  {
    path: '/CreationCenter/SendVideo',
    name: 'SendVideo',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/SendVideo.vue')
  },
  {
    path: '/CreationCenter/SendReport',
    name: 'SendReport',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/SendReport.vue')
  },
  {
    path: '/CreationCenter/SendNews',
    name: 'SendNews',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/SentNews.vue')
  },
  {
    path: '/CreationCenter/SendTinyArticle',
    name: 'SendTinyArticle',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/SendFuHeadLine.vue')
  },
  {
    path: '/CreationCenter/DataArticle',
    name: 'DataArticle',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/DataArticle.vue')
  },
  {
    path: '/CreationCenter/DataArticleDetail',
    name: 'DataArticleDetail',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/DataArticleDetail.vue')
  },
  {
    path: '/CreationCenter/DataFans',
    name: 'DataFans',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/DataFans.vue')
  },
  {
    path: '/CreationCenter/ManageArticle',
    name: 'ManageArticle',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/ManageArticle.vue')
  },
  {
    path: '/CreationCenter/ManageFollow',
    name: 'ManageFollow',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/ManageFollow.vue')
  },
  {
    path: '/CreationCenter/ManageComment',
    name: 'ManageComment',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/ManageComment.vue')
  },
  {
    path: '/CreationCenter/DataProfit',
    name: 'DataProfit',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/DataProfit.vue')
  },
  {
    path: '/CreationCenter/ManagePM',
    name: 'ManagePM',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/ManagePM.vue')
  },
  {
    path: '/CreationCenter/Option',
    name: 'Option',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/Option.vue')
  },
  {
    path: '/CreationCenter/Pay',
    name: 'Pay',
    component: () => import(/* webpackChunkName: "about" */ '../views/CreationCenter/Pay.vue')
  },
  {
    path: '/Video/Video',
    name: 'Video',
    component: () => import(/* webpackChunkName: "about" */ '../views/Video/Video.vue')
  },
  {
    path: '/Video/',
    name: 'VideoHome',
    component: () => import(/* webpackChunkName: "about" */ '../views/Video/VideoHome.vue')
  },
  {
    path: '/Video/CurriculumRanking',
    name: 'CurriculumRankingBestSelling',
    component: () => import(/* webpackChunkName: "about" */ '../views/Video/CurriculumRanking.vue')
  },
  {
    path: '/Video/CurriculumType',
    name: 'CurriculumType',
    component: () => import(/* webpackChunkName: "about" */ '../views/Video/CurriculumType.vue')
  },
  {
    path: '/Video/CurriculumBookShelf',
    name: 'CurriculumBookShelf',
    component: () => import(/* webpackChunkName: "about" */ '../views/Video/CurriculumBookShelf.vue')
  },
  {
    path: '/Video/CurriculumVideo',
    name: 'CurriculumVideo',
    component: () => import(/* webpackChunkName: "about" */ '../views/Video/CurriculumVideo.vue')
  },
  {
    path: '/Live',
    name: 'LiveHome',
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/zhuye.vue')
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/About.vue')
  },
  // {
  //   path: '/zb',
  //   name: 'zhibojiemian',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/Live/zhibojiemian.vue')
  // },
  {
    path: '/ks',
    name: '个人信息',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/个人信息.vue')
  },

  {
    path: '/tz',
    name: '直播通知',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/直播通知.vue')
  },
  {
    path: '/gz',
    name: '我的关注',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/我的关注.vue')
  },
  {
    path: '/ls',
    name: '观看历史',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/观看历史.vue')
  },
  {
    path: '/kb',
    name: '开播设置',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/开播设置.vue')
  },
  {
    path: '/xx',
    name: '直播间信息',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/直播间信息.vue')
  },
  {
    path: '/pk',
    name: 'PK设置',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/PK设置.vue')
  },
  {
    path: '/zl',
    name: '数据总览',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/数据总览.vue')
  },
  {
    path: '/tj',
    name: '礼物统计',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/礼物统计.vue')
  },
  {
    path: '/ph',
    name: '消费排行',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/消费排行.vue')
  },
  {
    path: '/zhu',
    name: 'Template',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Live/Template.vue')
  },
  {
    path: '/news',
    name: 'news',
    component: () => import(/* webpackChunkName: "about" */ '../views/News/NewsHome.vue')
  },
  {
    path: '/test',
    name: 'test',
    component: () => import(/* webpackChunkName: "about" */ '../views/News/Comments.vue')
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


router.beforeEach((to, from, next) => {
  if (to.path === '/Login') {
    const pathInfo = window.sessionStorage.getItem("path");
    if (!pathInfo) {
      window.sessionStorage.setItem('path', from.path);
    }
  }
  else if (to.path === '/CreationCenter') {
    const token = window.sessionStorage.getItem("idUser");
    if (!token) {
      window.sessionStorage.setItem('path', to.path);
      return next('/Login');
    }
  }
  return next();

})



export default router
